<?php
class AmazonWidget  extends CWidget{
    
	//输出字符串
	private $out = '';
    
    private $controller= '';
    
    private $action= '';
    
    public $category = '';

	public function init(){
        $this->controller = Yii::app()->controller->id;  
        $this->action = Yii::app()->controller->action->id; 
	}

	public function run(){
        $this->generateAmazon();
		echo $this->out;
	}

    public function generateAmazon(){
        $amazonCategory = array(
            'ios'=>'<SCRIPT charset="utf-8" type="text/javascript" src="http://ws-cn.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&MarketPlace=CN&ID=V20070822%2FCN%2Fgowhich-23%2F8010%2Ff5d01c2c-5592-4fb9-982b-e26ae2c86900&Operation=GetScriptTemplate"> </SCRIPT> <NOSCRIPT><A HREF="http://ws-cn.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&MarketPlace=CN&ID=V20070822%2FCN%2Fgowhich-23%2F8010%2Ff5d01c2c-5592-4fb9-982b-e26ae2c86900&Operation=NoScript">Amazon.cn Widgets</A></NOSCRIPT>',
            'php'=>'<SCRIPT charset="utf-8" type="text/javascript" src="http://ws-cn.amazon-adsystem.com/widgets/q?rt=tf_cw&ServiceVersion=20070822&MarketPlace=CN&ID=V20070822%2FCN%2Fgowhich-23%2F8010%2Faf75b87c-f8d1-4c3a-b9f2-17fe8d2827fc&Operation=GetScriptTemplate"> </SCRIPT> <NOSCRIPT><A HREF="http://ws-cn.amazon-adsystem.com/widgets/q?rt=tf_cw&ServiceVersion=20070822&MarketPlace=CN&ID=V20070822%2FCN%2Fgowhich-23%2F8010%2Faf75b87c-f8d1-4c3a-b9f2-17fe8d2827fc&Operation=NoScript">Amazon.cn Widgets</A></NOSCRIPT>',
            'javascript'=>'<SCRIPT charset="utf-8" type="text/javascript" src="http://ws-cn.amazon-adsystem.com/widgets/q?rt=tf_cw&ServiceVersion=20070822&MarketPlace=CN&ID=V20070822%2FCN%2Fgowhich-23%2F8010%2F853446a5-2458-4098-9ecc-d696f6698bab&Operation=GetScriptTemplate"> </SCRIPT> <NOSCRIPT><A HREF="http://ws-cn.amazon-adsystem.com/widgets/q?rt=tf_cw&ServiceVersion=20070822&MarketPlace=CN&ID=V20070822%2FCN%2Fgowhich-23%2F8010%2F853446a5-2458-4098-9ecc-d696f6698bab&Operation=NoScript">Amazon.cn Widgets</A></NOSCRIPT>',
            'java'=>'<SCRIPT charset="utf-8" type="text/javascript" src="http://ws-cn.amazon-adsystem.com/widgets/q?rt=tf_cw&ServiceVersion=20070822&MarketPlace=CN&ID=V20070822%2FCN%2Fgowhich-23%2F8010%2F0b30652e-754a-4806-ae22-284293b9b641&Operation=GetScriptTemplate"> </SCRIPT> <NOSCRIPT><A HREF="http://ws-cn.amazon-adsystem.com/widgets/q?rt=tf_cw&ServiceVersion=20070822&MarketPlace=CN&ID=V20070822%2FCN%2Fgowhich-23%2F8010%2F0b30652e-754a-4806-ae22-284293b9b641&Operation=NoScript">Amazon.cn Widgets</A></NOSCRIPT>',
            'linux'=>'<SCRIPT charset="utf-8" type="text/javascript" src="http://ws-cn.amazon-adsystem.com/widgets/q?rt=tf_cw&ServiceVersion=20070822&MarketPlace=CN&ID=V20070822%2FCN%2Fgowhich-23%2F8010%2F09f7c0c2-5ebf-4a54-a8a5-b0f900527595&Operation=GetScriptTemplate"> </SCRIPT> <NOSCRIPT><A HREF="http://ws-cn.amazon-adsystem.com/widgets/q?rt=tf_cw&ServiceVersion=20070822&MarketPlace=CN&ID=V20070822%2FCN%2Fgowhich-23%2F8010%2F09f7c0c2-5ebf-4a54-a8a5-b0f900527595&Operation=NoScript">Amazon.cn Widgets</A></NOSCRIPT>',
            'nginx'=>'<SCRIPT charset="utf-8" type="text/javascript" src="http://ws-cn.amazon-adsystem.com/widgets/q?rt=tf_cw&ServiceVersion=20070822&MarketPlace=CN&ID=V20070822%2FCN%2Fgowhich-23%2F8010%2F0e301b9f-bea2-43f3-9218-e69944da8fb5&Operation=GetScriptTemplate"> </SCRIPT> <NOSCRIPT><A HREF="http://ws-cn.amazon-adsystem.com/widgets/q?rt=tf_cw&ServiceVersion=20070822&MarketPlace=CN&ID=V20070822%2FCN%2Fgowhich-23%2F8010%2F0e301b9f-bea2-43f3-9218-e69944da8fb5&Operation=NoScript">Amazon.cn Widgets</A></NOSCRIPT>',
            'python'=>'<SCRIPT charset="utf-8" type="text/javascript" src="http://ws-cn.amazon-adsystem.com/widgets/q?rt=tf_cw&ServiceVersion=20070822&MarketPlace=CN&ID=V20070822%2FCN%2Fgowhich-23%2F8010%2F2bee852a-b685-4306-920b-37df87f8fbb7&Operation=GetScriptTemplate"> </SCRIPT> <NOSCRIPT><A HREF="http://ws-cn.amazon-adsystem.com/widgets/q?rt=tf_cw&ServiceVersion=20070822&MarketPlace=CN&ID=V20070822%2FCN%2Fgowhich-23%2F8010%2F2bee852a-b685-4306-920b-37df87f8fbb7&Operation=NoScript">Amazon.cn Widgets</A></NOSCRIPT>',
            'mysql'=>'<SCRIPT charset="utf-8" type="text/javascript" src="http://ws-cn.amazon-adsystem.com/widgets/q?rt=tf_cw&ServiceVersion=20070822&MarketPlace=CN&ID=V20070822%2FCN%2Fgowhich-23%2F8010%2Ffc4f80d6-5e3b-458e-98b9-df127f0f48e1&Operation=GetScriptTemplate"> </SCRIPT> <NOSCRIPT><A HREF="http://ws-cn.amazon-adsystem.com/widgets/q?rt=tf_cw&ServiceVersion=20070822&MarketPlace=CN&ID=V20070822%2FCN%2Fgowhich-23%2F8010%2Ffc4f80d6-5e3b-458e-98b9-df127f0f48e1&Operation=NoScript">Amazon.cn Widgets</A></NOSCRIPT>'
        );
        
        if(isset($amazonCategory[strtolower($this->category)])){
            $this->out .= $amazonCategory[strtolower($this->category)];
        }
    }
}



